<?php
/**
 * Created by PhpStorm.
 * User: yunpeng
 * Date: 2019/1/4
 * Time: 16:18
 */

namespace App\Admin\Controllers;

use App\Models\Order;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;


class SaleRankController    extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('销售额排名');
            //$content->body($this->Paginate());
            $content->body($this->grid());
        });
    }



    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Admin::grid(Order::class, function (Grid $grid) {
            // 设置初始排序条件
            $grid->model();
            $grid->seller_id('用户ID');
            $grid->seller_name('姓名');
            $grid->profit('销售额');
            $grid->disableFilter();
            $grid->disableExport();
            $grid->disableActions();
            $grid->disableCreateButton();
            //禁用批量删除按钮
            $grid->tools(function ($tools) {
                $tools->batch(function ($batch) {
                    $batch->disableDelete();
                });
            });
        });
    }



}
